package com.artpri.service.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.artpri.model.GoodsComment;
import com.artpri.model.GoodsCommentR;
import com.artpri.service.GoodsCommentService;

/**
 * @author ZhangSi
 */
public class GoodsCommentServiceImpl extends BaseService implements GoodsCommentService{

	@Override
	@Transactional(readOnly=true)
	public Map<GoodsComment, List<GoodsCommentR>> getGoodsCommentByGoods(int goodsNum) {
		
		Map<GoodsComment, List<GoodsCommentR>> map = null;
		
		List<GoodsComment> list = getGoodsCommentDao().getGoodsCommentByGoods(goodsNum);
		if (list != null && list.size() != 0) {
			map = new HashMap<GoodsComment, List<GoodsCommentR>>();
			for (Iterator<GoodsComment> it = list.iterator(); it.hasNext();) {
				GoodsComment goodsComment = (GoodsComment) it.next();
				List<GoodsCommentR> commentRs = getGoodsCommentRDao().getGoodsCommentRByComment(goodsComment.getGcommentId());
				map.put(goodsComment, commentRs);
			}
		}
		
		return map;
	}

}
